﻿using System.Collections.Generic;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using GitNet.WindowsApp.Models;
using LibGit2Sharp;

namespace GitNet.WindowsApp.GitView;

public partial class StatusView : UserControl
{
    public StatusView(List<Line>? deleteLines, List<Line>? addLines,string? state,string? path)
    {
        InitializeComponent();
        StateBlock = this.FindControl<TextBlock>("StateBlock");
        AddItems = this.FindControl<ItemsControl>("AddItems");
        DeleteItems = this.FindControl<ItemsControl>("DeleteItems");
        StateBlock.Text = state;
        AddItems.Items = addLines;
        DeleteItems.Items = deleteLines;
    }
    
    public StatusView(StatusModel model)
    {
        InitializeComponent();
        StateBlock = this.FindControl<TextBlock>("StateBlock");
        AddItems = this.FindControl<ItemsControl>("AddItems");
        DeleteItems = this.FindControl<ItemsControl>("DeleteItems");
        StateBlock.Text = model.State;
        AddItems.Items = model.AddContext;
        DeleteItems.Items = model.DeleteContext;
    }
    
    public StatusView()
    {
        InitializeComponent();
    }

    private void InitializeComponent()
    {
        AvaloniaXamlLoader.Load(this);
    }
}